package io.github.uicdb.liba.api.register;

import com.mojang.blaze3d.vertex.PoseStack;
import io.github.uicdb.liba.api.util.RenderHelper;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;

import javax.annotation.Nonnull;

public abstract class LazyScreen<T extends AbstractContainerMenu> extends AbstractContainerScreen<T> {
    public LazyScreen(T pMenu, Inventory pPlayerInventory, Component pTitle) {
        super(pMenu, pPlayerInventory, pTitle);
        this.imageHeight=getImageHeight();
        this.imageWidth=getImageWidth();
        init();
    }

    protected abstract int getImageWidth();
    protected abstract int getImageHeight();
    @Override
    public void render(@Nonnull PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) {
        renderBackground(pPoseStack);
        super.render(pPoseStack, pMouseX, pMouseY, pPartialTick);
        renderTooltip(pPoseStack,pMouseX,pMouseY);
    }

    @Override
    protected void renderBg(@Nonnull PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) {
        RenderHelper.renderGuiBackground(pPoseStack,leftPos,topPos,imageWidth,imageHeight);
        RenderHelper.renderSlots(pPoseStack,menu.slots,leftPos,topPos);
    }
}
